<?php

/**
 * AccountSupplier form.
 *
 * @package    form
 * @subpackage account_supplier
 * @version    SVN: $Id: sfPropelFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $
 */
class AccountSupplierForm extends BaseAccountSupplierForm
{
  public function configure()
  {
    if($this->isNew())
      $this->validatorSchema['contact_iden'] = new sfValidatorString(array('required' => true));
    $this->widgetSchema['default_owner_iden'] = new sfWidgetFormSelect(array('choices'=>AccountOwnerPeer::getList(),));
    $this->widgetSchema['currency_code'] = 
      new sfWidgetFormSelect(
        array(
          'choices'=>
            array_combine(
              ListCountriesPeer::getCurrencyCodeList(),
              ListCountriesPeer::getCurrencyCodeList()
            ),
        )
      );
    $this->widgetSchema['default_terms']->setOption('key_method','getTerm');
    $this->validatorSchema['default_terms']->setOption('column','term');
    $this->widgetSchema['status'] = 
      new sfWidgetFormSelect(
        array(
          'choices'=>
            array_combine(
              sfConfig::get('app_selection_customer_status'),
              sfConfig::get('app_selection_customer_status')
            ),
        )
      );
    $this->widgetSchema['vat_excempt_type'] = 
      new sfWidgetFormSelect(
        array(
          'choices'=>
            array_combine(
              sfConfig::get('app_selection_vat_excempt_type'),
              sfConfig::get('app_selection_vat_excempt_type')
            ),
        )
      );
    $this->widgetSchema->setLabels(
      array(
        'default_owner_iden'=>'Default Customer',
        'currency_code'=>'Currency',
        'default_terms'=>'Default Terms',
        'status'=>'Status',
        'credit_limit'=>'Credit Limit',
        'tin_number'=>'Tin#',
        'vat_excempt_type'=>'VAT Excempt',
        'product_line'=>'Products',
        'tax_codes'=>'Tax Codes',
        'remarks'=>'Remarks',
      )
    );
    $this->validatorSchema['remarks']->setOption('required',false);
  
  }
  
  public function setContactIden($c){
    $this->setDefault('contact_iden',$c);
  }
  
  public function getUrl(){
    if($this->isNew())
      return 'accountSupplier/insert';
    else
      return 'accountSupplier/update';
  }
  
  public function getDeleteUrl(){
    return 'accountSupplier/delete?iden='.$this->getObject()->getContactIden();
  }
  
  public function getResetUrl($contact){
    if($this->isNew())
      return 'accountSupplier/create?iden='.$contact->getIden();
    else
      return 'accountSupplier/edit?iden='.$this->getObject()->getContactIden();
  }


}
